package string;

import java.util.Scanner;

public class SensitiveWord {
    static String[] sensitives = {"敏感词", "妈的"};

    public static void main(String[] args) {

        String str = "听妈妈的话";
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入内容:");
//            String s = sc.next();输入空格会当成下一次输入的单词
            String s = sc.nextLine();
            s = relpace(s);
            System.out.println(s);
        }
    }

    private static String relpace(String s) {
        for (String sensitive : sensitives) {
            if (s.contains(sensitive)) {
                String temp = "";
                for (int i = 0; i < sensitive.length(); i++) {
                    temp += "*";
                }
//                s = s.replace(sensitive, temp);
                s = s.replaceAll(sensitive, temp);

            }
        }
        return s;
    }
}
